<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UserForm
 *
 * @author asmaa
 */
class APP_Form_UserForm extends Zend_Form{
    public function init()
    {
        $userName = new Zend_Form_Element_Text('userName');        
        $userName->setRequired(true)
                ->setLabel('Name: ')  
                ->addValidator('NotEmpty')
                ->addValidator('alnum')
                ->addValidator('StringLength',true,array('min'=>3,'max'=>16))
                ->addFilter('StringToLower');                
        $this->addElement($userName);

        $mail = new Zend_Form_Element_Text('mail');
        $mail->setRequired(true)
                ->setLabel('Email: ')
                ->addValidator('NotEmpty')
                ->addValidator('regex',false,array('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/'));
        $this->addElement($mail);
        
        $pswd = new Zend_Form_Element_Password('pswd');
        $pswd->setRequired(true)
                ->setLabel('Password: ')
                ->addValidator('NotEmpty');                
        $this->addElement($pswd);
        
        $job = new Zend_Form_Element_Text('job');        
        $job->setLabel('Job: ')  
                ->addValidator('alnum');
        $this->addElement($job);

        $bdate=new Zend_Form_Element_Text('bdate');
        $bdate->setLabel('Birthday: ')
                ->addValidator('regex',false,array('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/'));
        $this->addElement($bdate);
        
        $add = new Zend_Form_Element_Text('add');
        $add->setRequired(true)
                ->setLabel('Address: ')
                ->addValidator('alnum');
        $this->addElement($add);
   
        $country = new Zend_Form_Element_Text('country');
        $country->setLabel('Country: ')
                ->addValidator('alpha');
        $this->addElement($country);
        
        $crdtLmt = new Zend_Form_Element_Text('crdtLmt');
        $crdtLmt->setLabel('Credit Limit: ')
                ->addValidator('regex', false, array('/^[0-9]/'));
        $this->addElement($crdtLmt);
        
        $crdtNum = new Zend_Form_Element_Text('crdtNum');
        $crdtNum->setRequired(true)
                ->setLabel('Credit Card Number: ')
                ->addValidator('regex', false, array('/^[0-9]/'));
        $this->addElement($crdtNum);
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setRequired(true)
                ->setLabel('register');                
        $this->addElement($submit);

    }
}

?>
